<template>
  <div>
    <div class="pageheader">
      <XHeader :left-options="{backText:''}" :title="xheader.title" class="XHeader"></XHeader>
    </div>
    <!-- <div class="pagetop">
      <div class="toptab">
        <div
          v-for="(item,index) in tab"
          :key="index"
          class="item"
          :class="tabIndex==index?'active':''"
          @click="onTabTap(index)"
        >{{item}}</div>
      </div>
    </div>-->
    <div class="page">
      <div class="block" v-for="(item,index) in products" :key="index" style="  margin-top: 12px;">
        <div class="distribution" @click="onInfo(item)">
          <chimage class="img" :src="item.image"></chimage>
          <div class="content">
            <div class="title">{{item.goods_name}}</div>
            <div class="operation">
              <div class="price">￥{{item.internal_price}}</div>
              <div class="y-price">佣金：￥{{item.distribution_amount}}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import Product from '@/dll/product'

  export default {
    name: 'mallDistribution',
    data () {
      return {
        xheader: {
          title: '赚钱宝'
        },
        tab: ['佣金', '最新', '最热', '价格'],
        tabIndex: 0,
        products: [],
        limit: 20,
        page: 1,
        more: true,
        loding: false
      }
    },
    created () {
      this.getList()
    },
    methods: {
      onTabTap (index) {
        this.tabIndex = index
      },
      onInfo (item) {
        this.$router.push({
          name: 'mallDistributionInfo',
          params: { id: item.goods_sku }
        })
      },
      async getList () {
        let param = {
          limit: this.limit,
          page: this.page
        }
        this.$vux.loading.show({
          text: '请稍后'
        })
        let res = await Product.getDistributionProductList(param)
        this.$vux.loading.hide()
        if (res.code == 0) {
          this.products = res.data.data
        } else {
          this.$vux.confirm.show({
            title: '提示',
            content: res.msg,
            showCancelButton: false,
            onConfirm: () => {
              this.$router.back()
            }
          })
        }
      }
    }
  }
</script>

<style lang="less" scoped>
  .page {
    // padding-top: 45px;
    // padding-bottom: 25px;
  }

  .pagetop {
    display: block;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2;
  }

  .toptab {
    /* position: fixed; */
    box-sizing: border-box;
    width: 100%;
    top: 0;
    left: 0;
    display: flex;
    padding-left: 12px;
    padding-right: 12px;
    height: 45px;
    z-index: 9999;
    background-color: #fff;
  }

  .toptab > .item {
    flex: 1;
    height: 100%;
    display: block;
    line-height: 45px;
    font-size: 14px;
    color: #351009;
    opacity: 0.2;
    text-align: center;
    position: relative;
  }

  .toptab > .item.active {
    opacity: 1;
  }

  .toptab > .item.active::after {
    position: absolute;
    content: "";
    width: 100%;
    bottom: 0;
    left: 0;
    height: 1px;
    background: #b0290f;
  }

  .distribution {
    padding: 24px 16px;
    box-sizing: border-box;
    background-color: #fff;
    display: flex;
    align-items: center;
  }

  .distribution > .img {
    display: block;
    width: 90px;
    height: 90px;
    margin-right: 24px;
    background-color: #fbf8f7;
    background-size: cover;
  }

  .distribution > .content {
    flex: 1;
  }

  .distribution .title {
    font-size: 14px;
    color: #9f8d89;
    line-height: 20px;
    height: 40px;
    text-overflow: ellipsis;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .distribution .operation {
    margin-top: 15px;
    display: flex;
    align-items: center;
  }

  .distribution .price {
    flex: 1;
    font-size: 14px;
    color: #351009;
    line-height: 20px;
  }

  .distribution .y-price {
    font-size: 14px;
    color: #b02910;
    line-height: 20px;
  }

  .listitem {
    display: flex;
    align-items: center;
    height: 48px;
    box-sizing: border-box;
    padding: 14px 24px;
    position: relative;
    background-color: #fff;
  }

  .listitem::before {
    content: " ";
    display: inline-block;
    height: 6px;
    width: 6px;
    border-width: 2px 2px 0 0;
    border-color: #351009;
    border-style: solid;
    -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
    transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
    top: -2px;
    position: absolute;
    top: 50%;
    right: 0;
    margin-right: 24px;
    margin-top: -4px;
  }

  .listitem .text {
    flex: 1;
    font-size: 15px;
    color: #351009;
    line-height: 21px;
  }
</style>
